import React from 'react';
import { Toast } from 'antd-mobile';

export default class Index extends React.Component {
    constructor(props){
        super(props)
        this.state={
            id: props.match.params.id,
            content: '',
        }
    }
	componentDidMount(){
		document.title = '评论'
    }
    sub(){
        if(this.state.content===''){
            return Toast.fail('评论不能为空!',1)
        }
        Toast.loading()
        global.Ajax.hhtc_request("dynamic/pinglun",{id: this.state.id,content: this.state.content}).then(data=>{
            Toast.hide()
			if(data.code===1){
				Toast.success(data.msg,1,()=>{
                    this.props.history.goBack()
                })
            }else{
                Toast.fail(data.msg,1)
            }
		})
    }
	render(){
		return(
			<div className='' style={{paddingBottom: 70,minHeight: '100vh',background: '#F7F7F7',}}>
                <div style={{background: '#fff',paddingBottom: '1vw',}}>
                    <textarea className='sq_release' placeholder='来吧，尽情发挥~' onChange={(e)=>{
                        this.setState({
                            content: e.target.value
                        })
                    }}></textarea>
                </div>
                <p className='sq_sub' onClick={this.sub.bind(this)}>评论</p>
			</div>
		)
	}
}
